package com.triones.ljr.controller.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.triones.ljr.entity.dto.CheckCustomDO;
import com.triones.ljr.entity.vo.CheckCustomVO;
import com.triones.ljr.entity.vo.CustomCheckCustomVO;
import com.triones.ljr.service.CheckCustomService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * api - 我要迎检
 *
 * @Author: triones
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/checkCustom")
public class ApiCheckCustomController  extends BaseController {

    private final CheckCustomService checkCustomService;

    /**
     * 迎检列表（分页）
     */
    @GetMapping("/pageList")
    public TableDataInfo<CustomCheckCustomVO> pageList(CheckCustomDO dto, PageQuery pageQuery) {
        if (dto.getDeptId() == null) {
            throw new RuntimeException("部门id不能为空");
        }
        return checkCustomService.pageList(dto, pageQuery);
    }

    /**
     * 迎检详情
     */
    @GetMapping("/detail/{id}")
    public R<CustomCheckCustomVO> getInfo(@PathVariable @NotNull(message = "id不能为空") Long id) {
        return R.ok(checkCustomService.getInfo(id));
    }
}
